"""
-------------------------------
- File_Name: registers.py
- Date: 2025/2/16
- Author: yangzhide
- Email: xxzjyzd@126.com
- Description: app注册相关模块
-------------------------------
"""

from fastapi import FastAPI
from starlette.staticfiles import StaticFiles
from app.api import register_router
from app.api.swagger.docs import register_router_doc
from app.core.exceptions import register_exception_handler
from tortoise.contrib.fastapi import register_tortoise
from config import TORTOISE_ORM


def register_all(app: FastAPI):
    # 注册异常处理器
    register_exception_handler(app)
    # 注册路由
    register_router(app)
    # 离线swagger-ui 路由
    register_router_doc(app)


    # 挂载 静态文件路径
    app.mount("/static", StaticFiles(directory="static"), name="static")
    # tortoise
    register_tortoise(
        app,
        config=TORTOISE_ORM
    )